import $service from '../../../../service.js';
var log_id;
var selToID;
Page({
    data:{
        timeList:[],
        type:0
    },
    onLoad(e){
        log_id = e.log_id;
        if(!$service.isUndefinedAndEmpty(e.selToID)){
            selToID = e.selToID;
        }
        if(!$service.isUndefinedAndEmpty(e.type)){
            this.setData({
                type : e.type
            })
        }
    },
    onShow(){
        this.publicUtil_getInquiryLogImgList()
    },
    publicUtil_getInquiryLogImgList:function(){
        var jsonData ={
            "log_id" : log_id
        }
        console.log(jsonData)
        var jsonAjax = {
            "url": "publicUtil_getInquiryLogImgList.do",
            "jsonData": jsonData,
        }
        $service.getAjaxData(jsonAjax, this.publicUtil_getInquiryLogImgList_back);
    },
    publicUtil_getInquiryLogImgList_back:function(jsonBack){
        var data=$service.strToJson(jsonBack.data).data; 
        var imgList2 = data.imgList;
        for(var i = 0; i < imgList2.length;i++){
            imgList2[i].img_src = $service.getUserImgPub(imgList2[i].img_src)
        }
        this.setData({
            timeList : imgList2
        })
    },
    previewImage: function(e) { //图片放大
        var index = e.currentTarget.dataset.index;
        var all = [];
        all.push(this.data.timeList[index].img_src);
        all.forEach(item => {
            item = item.replace(/https/, 'http')
        })
        wx.previewImage({
            urls: all
        })
    },
    //删除
    closeImg(e){
        var index = e.currentTarget.dataset.index;
        var jsonData ={
            "img_id": this.data.timeList[index].img_id
        }
        var jsonAjax = {
            "url": "publicUtil_deleteInquiryLogImg.do",
            "jsonData": jsonData,
        }
        $service.getAjaxData(jsonAjax, this.publicUtil_deleteInquiryLogImg_back);
    },
    publicUtil_deleteInquiryLogImg_back(){
        var sendSystemMessageMsgText = '用户撤销图片'
        wx.txTic.sendCustomMessage(selToID,2)
        wx.txTic.sendSystemMessageMsg(selToID,sendSystemMessageMsgText);
        this.publicUtil_getInquiryLogImgList()
    }
})